/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Laporan.java
 *
 * Created on 13 Nov 11, 19:52:40
 */
package Login;

import Com.TransaksiParkirdanLaporan.Com.Laporan.*;
import Com.TransaksiParkirdanLaporan.Com.Transaksi.TransaksiParkirController;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Ardha
 */
public class MainForm extends javax.swing.JFrame {

    /** Creates new form Laporan */
    String jamMasukKaryawan;

    public MainForm(String jamMasukKaryawan) {
        initComponents();
        this.jamMasukKaryawan = jamMasukKaryawan;
        LaporanController.showDateAndClock(tanggalJamLabel);
        try {
            LoginController.showKaryawan(namaKaryawaniLabel, nipKaryawanLabel, roleLabel);
            LoginController.aturMenuKaryawan(this, roleLabel, laporanHarianMenuItem, laporanBulananMenuItem,
                    layananKeluarMenuItem, layananMasukMenuItem,
                    infoKaryawanPanel, logoutButton);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        headerLabel = new javax.swing.JLabel();
        separator = new javax.swing.JSeparator();
        infoKaryawanPanel = new javax.swing.JPanel();
        namaLabel = new javax.swing.JLabel();
        roleLabel = new javax.swing.JLabel();
        namaKaryawaniLabel = new javax.swing.JLabel();
        nipKaryawanLabel = new javax.swing.JLabel();
        logoutButton = new javax.swing.JButton();
        separatorInfoAdmin = new javax.swing.JSeparator();
        nipLabel1 = new javax.swing.JLabel();
        tanggalJamLabel = new javax.swing.JLabel();
        copyrightLabel = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        menubarMenu = new javax.swing.JMenu();
        laporanHarianMenuItem = new javax.swing.JMenuItem();
        laporanBulananMenuItem = new javax.swing.JMenuItem();
        layananMasukMenuItem = new javax.swing.JMenuItem();
        layananKeluarMenuItem = new javax.swing.JMenuItem();
        separatorMenu = new javax.swing.JPopupMenu.Separator();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenuBar = new javax.swing.JMenu();
        help = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Administrasi Page");

        mainPanel.setBackground(new java.awt.Color(255, 255, 255));

        headerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        headerLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Com/TransaksiParkirdanLaporan/Com/Laporan/headeradmin.jpg"))); // NOI18N

        infoKaryawanPanel.setBackground(new java.awt.Color(255, 255, 255));

        namaLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        namaLabel.setText("Nama");

        roleLabel.setFont(new java.awt.Font("Tahoma", 0, 18));

        namaKaryawaniLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        namaKaryawaniLabel.setText("Ardha, Vincentius");

        nipKaryawanLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        nipKaryawanLabel.setText("Admin_101");

        logoutButton.setForeground(new java.awt.Color(255, 0, 0));
        logoutButton.setText("Logout");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        nipLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        nipLabel1.setText("NIP");

        javax.swing.GroupLayout infoKaryawanPanelLayout = new javax.swing.GroupLayout(infoKaryawanPanel);
        infoKaryawanPanel.setLayout(infoKaryawanPanelLayout);
        infoKaryawanPanelLayout.setHorizontalGroup(
            infoKaryawanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(infoKaryawanPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(namaLabel)
                .addContainerGap(398, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, infoKaryawanPanelLayout.createSequentialGroup()
                .addContainerGap(317, Short.MAX_VALUE)
                .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(separatorInfoAdmin, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
            .addGroup(infoKaryawanPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(infoKaryawanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(roleLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, infoKaryawanPanelLayout.createSequentialGroup()
                        .addComponent(nipLabel1)
                        .addGap(13, 13, 13)
                        .addGroup(infoKaryawanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nipKaryawanLabel)
                            .addComponent(namaKaryawaniLabel))))
                .addContainerGap(296, Short.MAX_VALUE))
        );
        infoKaryawanPanelLayout.setVerticalGroup(
            infoKaryawanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(infoKaryawanPanelLayout.createSequentialGroup()
                .addComponent(logoutButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(separatorInfoAdmin, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(namaLabel)
                .addGroup(infoKaryawanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(infoKaryawanPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(namaKaryawaniLabel)
                        .addGap(36, 36, 36)
                        .addComponent(nipKaryawanLabel)
                        .addGap(27, 27, 27))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, infoKaryawanPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(nipLabel1)
                        .addGap(40, 40, 40)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(roleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );

        tanggalJamLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        tanggalJamLabel.setText("tanggal");

        copyrightLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        copyrightLabel.setText("The contents of this application are copyright © 2011 ATAI Company");

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(headerLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 903, Short.MAX_VALUE))
            .addComponent(separator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 913, Short.MAX_VALUE)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(copyrightLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 903, Short.MAX_VALUE))
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tanggalJamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 893, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(infoKaryawanPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(450, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(headerLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tanggalJamLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addComponent(infoKaryawanPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(copyrightLabel))
        );

        menubarMenu.setText("Menu");

        laporanHarianMenuItem.setText("Laporan Harian");
        laporanHarianMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                laporanHarianMenuItemActionPerformed(evt);
            }
        });
        menubarMenu.add(laporanHarianMenuItem);

        laporanBulananMenuItem.setText("Laporan Bulanan");
        laporanBulananMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                laporanBulananMenuItemActionPerformed(evt);
            }
        });
        menubarMenu.add(laporanBulananMenuItem);

        layananMasukMenuItem.setText("Layanan Masuk");
        layananMasukMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                layananMasukMenuItemActionPerformed(evt);
            }
        });
        menubarMenu.add(layananMasukMenuItem);

        layananKeluarMenuItem.setText("Layanan Keluar");
        layananKeluarMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                layananKeluarMenuItemActionPerformed(evt);
            }
        });
        menubarMenu.add(layananKeluarMenuItem);
        menubarMenu.add(separatorMenu);

        exitMenuItem.setForeground(new java.awt.Color(255, 0, 0));
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        menubarMenu.add(exitMenuItem);

        menuBar.add(menubarMenu);

        helpMenuBar.setMnemonic('H');
        helpMenuBar.setText("Help");

        help.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        help.setText("SPPKB Help");
        help.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpActionPerformed(evt);
            }
        });
        helpMenuBar.add(help);

        menuBar.add(helpMenuBar);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-929)/2, (screenSize.height-671)/2, 929, 671);
    }// </editor-fold>//GEN-END:initComponents

    private void laporanHarianMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_laporanHarianMenuItemActionPerformed
        // TODO add your handling code here:
        LaporanController.openKeuanganHarianDialog(this);
    }//GEN-LAST:event_laporanHarianMenuItemActionPerformed

    private void laporanBulananMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_laporanBulananMenuItemActionPerformed
        // TODO add your handling code here:
        LaporanController.openKeuanganBulananDialog(this);
    }//GEN-LAST:event_laporanBulananMenuItemActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void layananKeluarMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_layananKeluarMenuItemActionPerformed
        // TODO add your handling code here:
        TransaksiParkirController.openLayananKeluar(this, jamMasukKaryawan);
    }//GEN-LAST:event_layananKeluarMenuItemActionPerformed

    private void layananMasukMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_layananMasukMenuItemActionPerformed
        // TODO add your handling code here:
        TransaksiParkirController.openLayananMasuk(this, jamMasukKaryawan);
    }//GEN-LAST:event_layananMasukMenuItemActionPerformed

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        try {
            // TODO add your handling code here:
            Karyawan.logout();
            this.setVisible(false);
            LoginController.openLoginForm();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }//GEN-LAST:event_logoutButtonActionPerformed

    private void helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpActionPerformed
        // TODO add your handling code here:
        LoginController.showHelp();
    }//GEN-LAST:event_helpActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel copyrightLabel;
    public javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JLabel headerLabel;
    private javax.swing.JMenuItem help;
    private javax.swing.JMenu helpMenuBar;
    private javax.swing.JPanel infoKaryawanPanel;
    private javax.swing.JMenuItem laporanBulananMenuItem;
    private javax.swing.JMenuItem laporanHarianMenuItem;
    private javax.swing.JMenuItem layananKeluarMenuItem;
    private javax.swing.JMenuItem layananMasukMenuItem;
    private javax.swing.JButton logoutButton;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    public javax.swing.JMenu menubarMenu;
    public javax.swing.JLabel namaKaryawaniLabel;
    private javax.swing.JLabel namaLabel;
    public javax.swing.JLabel nipKaryawanLabel;
    private javax.swing.JLabel nipLabel1;
    private javax.swing.JLabel roleLabel;
    private javax.swing.JSeparator separator;
    private javax.swing.JSeparator separatorInfoAdmin;
    private javax.swing.JPopupMenu.Separator separatorMenu;
    private javax.swing.JLabel tanggalJamLabel;
    // End of variables declaration//GEN-END:variables
}
